#include <iostream>
#include <unistd.h>


using namespace std;
class TextProgressBar
{
public:
    TextProgressBar(int range): range_( range ){
        printChar('|', 1);
        printChar(' ', 60);
        printChar('|', 1);
        printChar('\b', 61);
    }
    ~TextProgressBar(){
        printChar( '\n', 1);
    }
    void done(){
        printChar( '\n', 1);
        
    }
            
    void setProgress(int current){
        static int n = 0;
        double f = (double )current / range_;
        int num = double (60) * f;
        printChar('-', num - n );
        n = num;
    }
    
private:
    void printChar(char c, int count){
        for(int i = 0; i < count; ++ i)
        {
            std::cout << c << flush;
        }
              
    }
    

private:
    int range_;
};    
int main()
{
    TextProgressBar tpb(60);
    for (int i = 1; i <= 60 ; ++i ){
        tpb.setProgress( i );
        // sleep(1);
    }
    
}
